var t = require;
var e = module;
var o = exports;
var a,
    i =
        (this && this.__extends) ||
        ((a = function (t, e) {
            return (a =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (t, e) {
                        t.__proto__ = e;
                    }) ||
                function (t, e) {
                    for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
                })(t, e);
        }),
        function (t, e) {
            a(t, e);
            function o() {
                this.constructor = t;
            }
            t.prototype = null === e ? Object.create(e) : ((o.prototype = e.prototype), new o());
        }),
    n =
        (this && this.__decorate) ||
        function (t, e, o, a) {
            var i,
                n = arguments.length,
                r = n < 3 ? e : null === a ? (a = Object.getOwnPropertyDescriptor(e, o)) : a;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, a);
            else
                for (var s = t.length - 1; s >= 0; s--)
                    (i = t[s]) && (r = (n < 3 ? i(r) : n > 3 ? i(e, o, r) : i(e, o)) || r);
            return n > 3 && r && Object.defineProperty(e, o, r), r;
        };
Object.defineProperty(o, "__esModule", {value: !0});
var r = cc._decorator,
    s = r.ccclass,
    c = r.property,
    p =
        (r.menu,
        (function (t) {
            i(e, t);
            function e() {
                var e = (null !== t && t.apply(this, arguments)) || this;
                e.viewSprite = null;
                e.animationNode = null;
                e.curMoveIndexTime = 0;
                e.maxTime = 2e3;
                e.endWpos = cc.Vec2.ZERO;
                e.centerPos = cc.Vec2.ZERO;
                e.canPlay = !1;
                e.startPos = cc.Vec2.ZERO;
                return e;
            }
            e.prototype.update = function () {
                if (this.canPlay)
                    if (Date.now() - this.curMoveIndexTime < this.maxTime) this.follow();
                    else {
                        this.follow();
                        this.canPlay = !1;
                        QLooperNode.putNode(this.node);
                    }
            };
            e.prototype.follow = function () {
                var t = Math.min(Date.now() - this.curMoveIndexTime, this.maxTime) / this.maxTime,
                    e = this.startPos,
                    o = e.add(this.centerPos.sub(e).mul(t)),
                    a = this.centerPos.add(this.endWpos.sub(this.centerPos).mul(t)).sub(o).mul(t),
                    i = o.add(a);
                this.node.setPosition(this.node.parent.convertToNodeSpaceAR(i));
            };
            e.prototype.playMoveTime = function (t, e) {
                var o = this;
                this.updateSprite(e);
                this.node.scaleY = 0.5;
                this.node.scaleX = 0.5;
                var a = [];
                this.animationNode.scale = 0;
                this.animationNode.stopAllActions();
                a.push(cc.scaleTo(0.2, 1).easing(cc.easeBackIn()));
                a.push(cc.delayTime(0.3));
                a.push(
                    cc.callFunc(function () {
                        o.endWpos = t;
                        o.curMoveIndexTime = Date.now();
                        o.maxTime = 2e3;
                        o.canPlay = !0;
                        o.spriteAnimal(o.maxTime / 1e3);
                        var e = cc.v2(o.node.convertToWorldSpaceAR(cc.Vec2.ZERO));
                        o.startPos = e;
                        o.centerPos = e.add(t).mul(0.5);
                        o.centerPos.x += 300;
                    }, this)
                );
                this.animationNode.runAction(cc.sequence(a));
            };
            e.prototype.spriteAnimal = function (t) {
                var e = this.viewSprite.node;
                e.angle = 0;
                e.runAction(cc.rotateBy(t, -(Math.floor(160 * Math.random()) + 320)));
            };
            e.prototype.updateSprite = function (t) {
                SpriteView.setFameView(t, this.viewSprite);
            };
            n([c(cc.Sprite)], e.prototype, "viewSprite", void 0);
            n([c(cc.Node)], e.prototype, "animationNode", void 0);
            return n([s], e);
        })(cc.Component));
o.default = p;
